package com.zdsoft.blp.zongbuju.wode.activity;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import com.zdsoft.blp.R;
import com.zdsoft.blp.gongyong.fanhui.FanHuiView;
import com.zdsoft.blp.gongyong.net.BaseActivity;
import com.zdsoft.blp.zongbuju.shouye.linliquan.activity.LLLunTanActivity;
import com.zdsoft.blp.zongbuju.shouye.linliquan.activity.LLLvYouActivity;
import com.zdsoft.blp.zongbuju.shouye.linliquan.activity.LLPinCheActivitv;
import com.zdsoft.blp.zongbuju.shouye.linliquan.activity.LLShiChangActivitv;
import com.zdsoft.blp.zongbuju.shouye.linliquan.activity.LLXunWuActivity;
import com.zdsoft.blp.zongbuju.shouye.linliquan.activity.LLZhaoPinActivity;
import com.zdsoft.blp.zongbuju.shouye.linliquan.activity.LLZuLinActivity;
import com.zdsoft.blp.zongbuju.wode.adapter.GrzxAdapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2016/9/1.
 */
public class WoDeFaBuActivity extends BaseActivity {

    private ListView lv_wdfb;
    private List<Map<String, Object>> list;
    private FanHuiView fh;

    @Override
    protected void init() {
        setContentView(R.layout.wodefabu_wode);
        fh=find(R.id.fh);
        fh.getTv_title().setText("我的发布");

        lv_wdfb = find(R.id.lv_wdfb);


        GrzxAdapter adapter = new GrzxAdapter(getData(),getApplicationContext());

        lv_wdfb.setAdapter(adapter);

        lv_wdfb.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                String title=getData().get(position).get("title").toString();
                Intent intent=null;
                switch (title){
                    case "我的论坛":
                        intent=new Intent(getApplicationContext(), LLLunTanActivity.class);
                        intent.putExtra("source",2);
                        break;
                    case "我的二手":
                        intent=new Intent(getApplicationContext(), LLShiChangActivitv.class);
                        intent.putExtra("source",2);
                        break;
                    case "我的旅行":
                        intent=new Intent(getApplicationContext(), LLLvYouActivity.class);
                        intent.putExtra("title","自驾组团");
                        intent.putExtra("source",2);
                        break;
                    case "我的拼车":
                        intent=new Intent(getApplicationContext(), LLPinCheActivitv.class);
                        intent.putExtra("source",2);
                        break;
                    case "求职招聘":
                        intent=new Intent(getApplicationContext(), LLZhaoPinActivity.class);
                        intent.putExtra("source",2);
                        break;
                    case "寻物招领":
                        intent=new Intent(getApplicationContext(), LLXunWuActivity.class);
                        intent.putExtra("source",2);
                        break;
                    case "房屋租赁":
                        intent=new Intent(getApplicationContext(), LLZuLinActivity.class);
                        intent.putExtra("source",2);
                        break;

                }
                startActivity(intent);
            }
        });
    }

    public List<Map<String,Object>> getData(){
        list = new ArrayList<>();

        Map<String,Object> map = new HashMap<>();
        map.put("image",R.drawable.wdlt);
        map.put("title","我的论坛");
        list.add(map);

        Map<String,Object> map1 = new HashMap<>();
        map1.put("image",R.drawable.wdes);
        map1.put("title","我的二手");
        list.add(map1);

        Map<String,Object> map2 = new HashMap<>();
        map2.put("image",R.drawable.wdlx);
        map2.put("title","我的旅行");
        list.add(map2);

        Map<String,Object> map3 = new HashMap<>();
        map3.put("image",R.drawable.wdpc);
        map3.put("title","我的拼车");
        list.add(map3);

        Map<String,Object> map4 = new HashMap<>();
        map4.put("image",R.drawable.wdqzzp);
        map4.put("title","求职招聘");
        list.add(map4);

        Map<String,Object> map5 = new HashMap<>();
        map5.put("image",R.drawable.wdxwzl);
        map5.put("title","寻物招领");
        list.add(map5);

        Map<String,Object> map6 = new HashMap<>();
        map6.put("image",R.drawable.wdfwzs);
        map6.put("title","房屋租赁");
        list.add(map6);

        return list;
    }

}
